import { createStore } from 'redux'


//从redux-persist插件中导入实现store持久化的方法
import { persistStore, persistReducer } from 'redux-persist'
//导入持久化存储引擎 localstorage sessionStorage
import storage from'redux-persist/lib/storage' //默认存储在localstorage

//导入纯函数
import {reducer} from './reducer'


//使用persistReducer对根reducer进行持久化处理
const persistedReducer = persistReducer( { key:'redux',storage } , reducer)

//使用持久化处理后的根reducer 创建store
export var store = createStore(persistedReducer)

//使用persistStore对store进行持久化处理
export var persistor = persistStore(store)